home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / Virtual User 1.0 / Example Libraries / StandardDialogsLib.vu < prev    next >
Text File  |  1991-01-25  |  2KB  |  58 lines

  1. #
  2. #    File:        StandardDialogs.vu
  3. #
  4. #    Contains:    Sample tasks for working with standard Macintosh dialogs
  5. #
  6. #    Written by:    Sean Flynn, Jay Jessen, and P. Nagarajan
  7. #
  8. #    Copyright:    © 1990 by Apple Computer, Inc., all rights reserved.
  9. #
  10. #    Change History:
  11. #
  12. #        4/25/89       SLF         Created.
  13. #
  14. #    To Do:
  15. #
  16.  
  17. # *****************************************************************************************
  18. # Handle a simple case of work with the Standard file dialog.
  19. task DoSaveAs( save_title := 'Untitled' ) begin
  20.     select [menuItem t: "Save As"];                #menu selection
  21.     type k:{ save_title };                        #literal key strokes
  22.     select [button t:"Save"];                    #button press
  23.     # if the file exists, the "Do you want to replace dialog will come up
  24.     # This if statement recognizes that dialog and deals with it
  25.     if match[window s:dialog k:{ [button t:"Yes"], [button t:"No"] } ] do
  26.         select[button t:"Yes"]; 
  27. end; # task DoSaveAs
  28.  
  29.  
  30. # *****************************************************************************************
  31. task SelectFromStandardFile(path_to_file,maximum_nesting_depth := 64) begin
  32. #         This task will select a file from the standard    file dialog.  It 
  33. #        navigates through the dialog by way of the keyboard.
  34. #        It takes two parameters, one is a list of file prefixes that will take
  35. #        the virtual user down to the file you want selected. The list must 
  36. #        contain the strings that VU can type to reach the file.  They may be the
  37. #        complete folder names or enough of the folder name to distinguish them 
  38. #        from sibling folders.  The second is a number indicating the current 
  39. #        directory's maximum depth.  VU uses this number to get up to the top using
  40. #        command-up arrow.  By default, it is 64 so it isn't necessary to pass
  41. #        the second parameter.  The operation may be made faster, however, if you
  42. #        pass it a smaller number.  A sample call might look like this:
  43. #
  44. #            SelectFromStandardFile( { "HD","MPW","Interf","Cinclu","Palettes" },10 );
  45. #
  46.     pressKey keystrokes: { commandKey };
  47.     for i := 1 to maximum_nesting_depth type keystrokes: { upArrowKey };
  48.     releaseKey keystrokes: { commandKey };
  49.     path_size := card(path_to_file);
  50.     for i := 2 to path_size - 1 type keystrokes: { path_to_file[i],returnKey };
  51.     type keystrokes: { path_to_file[path_size] };
  52. end;
  53.  
  54.  
  55. (* Example Usage: 
  56.     SelectFromStandardFile( { "HD","MPW","Interf","Cinclu","Palettes" },10 );
  57.     DoSaveAs("junk");
  58.  *)